import { useBpmnData } from '@/store/modules/bpmnData';
import { storeToRefs } from 'pinia';

const bpmnDataStore = useBpmnData();
let { xmlId, xmlName } = storeToRefs(bpmnDataStore);

export default (key: string, name: string): string => {
  const keyId =
    xmlId.value === '' || xmlId.value === null ? `Process_${key}` : xmlId.value;
  const modelName =
    xmlName.value === '' || xmlName.value === null ? `${name}` : xmlName.value;

  return `<?xml version="1.0" encoding="UTF-8"?>
  <bpmn2:definitions 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL"
    xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
    xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
    xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
    xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"
    id="sample-diagram"
    targetNamespace="http://activiti.org/bpmn">
    <bpmn2:process id="Process_${keyId}" name="${modelName}" isExecutable="true">
    </bpmn2:process>
    <bpmndi:BPMNDiagram id="BPMNDiagram_1">
      <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_${keyId}">
      </bpmndi:BPMNPlane>
    </bpmndi:BPMNDiagram>
  </bpmn2:definitions>`;
};
